package cn.com.headfree.userinfo.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.headfree.base.controller.ExBaseController;
import cn.com.headfree.base.controller.ResultData;
import cn.com.headfree.userinfo.service.IPrizeService;
import cn.com.headfree.vo.PrizeVo;


/**
 * 奖项controller
 * @author sai
 *
 */
@Controller
@RequestMapping(value = "/prize", produces = "application/json;charset=UTF-8")
public class PrizeController extends ExBaseController {
	private static final Logger LOG = LogManager.getLogger(PrizeController.class);
	@Autowired
	private IPrizeService prizeService;
	
	  @RequestMapping("/getPrizesByErpNoAndTime")
	    @ResponseBody
	    public ResultData getPrizesByErpNoAndTime( HttpServletRequest request,String startDate,String endDate,String erpNo) {
	        ResultData result = new ResultData();
	        try {
	        	//获取竞赛考试奖项
	        	List<PrizeVo> contestList=prizeService.getContestPrizes(startDate,endDate,erpNo);
	        	//获取个人荣誉奖项
	        	List<PrizeVo> honorList=prizeService.getHonorPrizes(startDate,endDate,erpNo);
	        	//获取科技奖励奖项
	        	List<PrizeVo> tecManInnovList=prizeService.getTecManInnovPrizes(startDate,endDate,erpNo);
	        	List<PrizeVo> list=new ArrayList<PrizeVo>();
	        	list.addAll(contestList);
	        	list.addAll(honorList);
	        	list.addAll(tecManInnovList);
	            result.setData(list);
	            LOG.info("查询获奖信息成功！");
	        } catch (Exception e) {
	            result.setErrorMsg("查询获奖信息异常");
	            result.setSuccess(false);
	            LOG.error("查询获奖信息异常", e);
	        }
	        return result;
	    }
	

}
